Imports System.Data.SqlClient
Imports System.Data
Partial Class Admin_frmWomen
    Inherits System.Web.UI.Page
    Dim _bo As New Bo
    Dim _EmployeeId As String
    Dim cntProduct As Integer
    Dim row, i As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            ViewState("min") = 1
            ViewState("max") = 8
        End If
        _EmployeeId = Session("EmpId")
        If _EmployeeId = "" Then
            Response.Redirect("../Client/frmLogin.aspx")
        End If
        Dim dtTable As New DataTable
        dtTable = _bo.getWomenProducts(ViewState("min"), ViewState("max"))
        DataList.DataSource = dtTable
        DataList.DataBind()
    End Sub
    Protected Sub DataList_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList.EditCommand
        If e.CommandName = "Edit" Then
            Dim lnk1 As LinkButton = e.Item.FindControl("Lnk")
            Session("EmpId") = _EmployeeId
            Response.Redirect("frmModifyProduct.aspx?ProductId=" & lnk1.Text)
        End If
    End Sub
    Protected Sub lnkPrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkPrevious.Click
        _bo.getWomenProducts(ViewState("min"), ViewState("max")).Rows.Clear()
        cntProduct = _bo.counttotproductCategory("W")
        ViewState("min") = Val(ViewState("min")) - 8
        ViewState("max") = Val(ViewState("max")) - 8
        DataList.DataSource = _bo.getWomenProducts(ViewState("min"), ViewState("max"))
        DataList.DataBind()
        If ViewState("min") <= 1 Then
            lnkPrevious.Enabled = False
        End If
        If ViewState("max") <= cntProduct Then
            lnkNext.Enabled = True
        End If
    End Sub
    Protected Sub lnkNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNext.Click
        _bo.getWomenProducts(ViewState("min"), ViewState("max")).Rows.Clear()
        cntProduct = _bo.counttotproductCategory("W")
        ViewState("min") = Val(ViewState("min")) + 8
        ViewState("max") = Val(ViewState("max")) + 8
        DataList.DataSource = _bo.getWomenProducts(ViewState("min"), ViewState("max"))
        DataList.DataBind()
        If ViewState("max") > cntProduct Then
            lnkNext.Enabled = False
        End If
        If ViewState("min") > 1 Then
            lnkPrevious.Enabled = True
        End If
    End Sub
End Class
